import {POST, DELETE, GET, PUT} from "./request";

// =========== point
export function addPoint(data) {
  return POST('/api/test/point', data)
}

export function deletePoint(data) {
  return DELETE('/api/test/point', data)
}

export function queryPoint(data) {
  return GET('/api/test/point', data)
}

export function updatePoint(data) {
  return PUT('/api/test/point', data)
}

// ============= line
export function addLine(data) {
  return POST('/api/test/line', data)
}

export function deleteLine(data) {
  return DELETE('/api/test/line', data)
}

export function queryLine(data) {
  return GET('/api/test/line', data)
}

export function updateLine(data) {
  return PUT('/api/test/line', data)
}

// ============= face
export function addFace(data) {
  return POST('/api/test/face', data)
}

export function deleteFace(data) {
  return DELETE('/api/test/face', data)
}

export function queryFace(data) {
  return GET('/api/test/face', data)
}

export function updateFace(data) {
  return PUT('/api/test/face', data)
}

const api = {
  addPoint,
  deletePoint,
  queryPoint,
  updatePoint,

  addLine,
  deleteLine,
  queryLine,
  updateLine,

  addFace,
  deleteFace,
  queryFace,
  updateFace
}

export default api;

(() => {
  async function addPoint() {
    const addPoint = await api.addPoint({buildingId: 1, floorId: 1, name: '1', desc: '1', point: [59, 1, -1], userData: {test: 'test'}});
    console.log('addPoint: ', addPoint)
  }


  async function deletePoint() {
    const deletePoint = await api.deletePoint({id: 1, ids: [1, 6, 8]});
    console.log('deletePoint: ', deletePoint)
  }


  async function queryPoint() {
    const queryPoint = await api.queryPoint();
    console.log('queryPoint: ', queryPoint)
  }


  async function updatePoint() {
    const updatePoint = await api.updatePoint({id: 8, buildingId: 10, floorId: 10, name: 111, desc: '111', point: [451, 1, 310], userData: {test2: 'test'}});
    console.log('updatePoint: ', updatePoint)
  }


  async function addLine() {
    const addLine = await api.addLine({buildingId: 1, floorId: 1, name: '1', desc: '1', points: [[62, 1, -28]], userData: {test: 'test'}});
    console.log('addLine: ', addLine)
  }


  async function deleteLine() {
    const deleteLine = await api.deleteLine({id: 1, ids: [1, 6, 8]});
    console.log('deleteLine: ', deleteLine)
  }


  async function queryLine() {
    const queryLine = await api.queryLine();
    console.log('queryLine: ', queryLine)
  }


  async function updateLine() {
    const updateLine = await api.updateLine({id: 3, buildingId: 10, floorId: 10, name: 111, desc: '111', points: [[111, 1, 56], [13, 1, 24]], userData: {test2: 'test'}});
    console.log('updateLine: ', updateLine)
  }


  async function addFace() {
    const addFace = await api.addFace({buildingId: 1, floorId: 1, name: '1', desc: '1', points: [[62, 1, -28]], userData: {test: 'test'}});
    console.log('addFace: ', addFace)
  }


  async function deleteFace() {
    const deleteFace = await api.deleteFace({id: 1, ids: [1, 6, 8]});
    console.log('deleteFace: ', deleteFace)
  }


  async function queryFace() {
    const queryFace = await api.queryFace();
    console.log('queryFace: ', queryFace)
  }


  async function updateFace() {
    const updateFace = await api.updateFace({id: 3, buildingId: 10, floorId: 10, name: 111, desc: '111', points: [[111, 1, 56], [13, 1, 24]], userData: {test2: 'test'}});
    console.log('updateFace: ', updateFace)
  }

  // queryPoint()
  // updatePoint()
  // addPoint()
  // deletePoint()
  // queryPoint()
  //
  // queryLine()
  // updateLine()
  // addLine()
  // deleteLine()
  // queryLine()
  //
  // queryFace()
  // updateFace()
  // addFace()
  // deleteFace()
  // queryFace()
})()
